#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
#endregion

namespace KLib.Physics.Collisions
{
    public struct Contact : IEquatable<Contact>
    {
        #region Fields
        public Vector2 Position;
        public Vector2 Normal;
        public float Separation;
        internal float NormalImpulse;
        internal float TangentImpulse;
        internal float MassNormal;
        internal float MassTangent;
        internal float NormalVelocityBias;
        internal float NormalImpulseBias;
        internal Vector2 R1;
        internal Vector2 R2;
        internal float BounceVelocity;
        #endregion

        #region Properties

        #endregion

        #region Initialization

        public Contact(Vector2 position, Vector2 normal, float separation)
        {
            this.Position = position;
            this.Normal = normal;
            this.Separation = separation;
            this.NormalImpulse = 0f;
            this.TangentImpulse = 0f;
            this.MassNormal = 0f;
            this.MassTangent = 0f;
            this.NormalVelocityBias = 0f;
            this.NormalImpulseBias = 0f;
            this.R1 = Vector2.Zero;
            this.R2 = Vector2.Zero;
            this.BounceVelocity = 0f;
        }

        #endregion

        #region Methods
        public void SetMassNormal(float massNormal)
        {
            this.MassNormal = massNormal;
        }

        public void SetMassTangent(float massTangent)
        {
            this.MassTangent = massTangent;
        }

        public void SetBias(float bias)
        {
            this.NormalVelocityBias = bias;
        }

        public void SetNormalImpulse(float normalImpulse)
        {
            NormalImpulse = normalImpulse;
        }

        public void SetTangentImpulse(float tangentImpulse)
        {
            TangentImpulse = tangentImpulse;
        } 
        #endregion

        #region Operator Overrides
        public static bool operator ==(Contact contact1, Contact contact2)
        {
            return contact1.Equals(contact2);
        }

        public static bool operator !=(Contact contact1, Contact contact2)
        {
            return !contact1.Equals(contact2);
        }
        #endregion

        #region Helper Methods

        #endregion

        #region IEquatable<Contact> Members

        public bool Equals(Contact other)
        {
            return this.GetHashCode() == other.GetHashCode();
        }

        #endregion
    }
}
